package com.andy.buyu.server.dto;

import com.andy.buyu.server.game.GameUser;
import com.andy.buyu.server.game.Room;

import io.netty.buffer.ByteBuf;

/**
 * 进入游戏
 * @author cuiwm
 */
public class EnterGameMessage extends BaseMessage{
	
    private GameUser user;
    
    public EnterGameMessage(GameUser user) {
    	this.user = user;
	}

	@Override
	public void writeBody(ByteBuf buf) {
		Room room = user.getRoom();
		buf.writeInt(room.getId());
		writeString(buf,room.getGame().getMapRes());
		buf.writeInt(room.getGame().getStageId());
		GameUser[] users = room.getUsers();
		buf.writeInt(room.getMsize());
		for(GameUser us:users){
			if(us != null) {
				new UserEnterMessage(us).writeBody(buf);
			}
		}
	}


}